//------------------------------------------------------------------------------
// Copyright (C) 2007-2008 Samuel Lacroix
// This file is part of Visual Local History 2005
// 
// Visual Local History 2005 is free software; you can redistribute it
// and/or modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
// 
// Visual Local History 2005 is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Visual Local History 2005; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//------------------------------------------------------------------------------

#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Text::RegularExpressions;

#include "Connect.h"
#include "Config.h"


namespace HistoryAddIn {

	/// <summary>
	/// Summary for FormConfig
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class FormConfig : public System::Windows::Forms::Form
	{
	public:
	    property Connect ^ ConnectObject
        {
            Connect ^ get() { return connectObject; }
            void set(Connect ^ value) 
            { 
                connectObject = value; 
            }
        }

		FormConfig(void) :
		initDone(false)
		{
			InitializeComponent();
			
			// help labels
			labelCurrentTitle->Text = Connect::DiffToolArgsChar + Connect::DiffToolArgs::CurrentRevision;
			labelCurrentNameTitle->Text = Connect::DiffToolArgsChar + Connect::DiffToolArgs::CurrentRevisionName;
			labelOldTitle->Text = Connect::DiffToolArgsChar + Connect::DiffToolArgs::SelectedBackup;
			labelOldNameTitle->Text = Connect::DiffToolArgsChar + Connect::DiffToolArgs::SelectedBackupName;
			
			// predefined args : table
			PredefinedArgs = gcnew Hashtable;
			PredefinedArgs->Add("TortoiseMerge", " /base:" + labelCurrentTitle->Text + " /mine:" + labelOldTitle->Text + " /basename:" + labelCurrentNameTitle->Text + " /minename:" + labelOldNameTitle->Text);
			PredefinedArgs->Add("WinMerge", " /dl " + labelCurrentNameTitle->Text + " /dr " +  labelOldNameTitle->Text + " " + labelCurrentTitle->Text + " " + labelOldTitle->Text);
			PredefinedArgs->Add("Microsoft Diff and Merge", labelCurrentTitle->Text + " " +  labelOldTitle->Text + " " + labelCurrentNameTitle->Text + " " + labelOldNameTitle->Text);
			PredefinedArgs->Add("Beyond Compare 2", labelCurrentTitle->Text + " " +  labelOldTitle->Text + " /title1=" + labelCurrentNameTitle->Text + " /title2=" + labelOldNameTitle->Text);
			PredefinedArgs->Add("Araxis Merge", " /title1:" + labelCurrentNameTitle->Text + " /title2:" + labelOldNameTitle->Text + " " + labelCurrentTitle->Text + " " + labelOldTitle->Text);
			
			// predefined args : combobox
			IDictionaryEnumerator^ Enumerator = PredefinedArgs->GetEnumerator();
            while (Enumerator->MoveNext())
            {
                comboBoxPredefinedTools->Items->Add((String^) Enumerator->Key);
            }     
            if (comboBoxPredefinedTools->Items->Count > 0)
                comboBoxPredefinedTools->SelectedIndex = 0;
                
            // detected tools : table
            DetectedTools = gcnew Hashtable;
            String^ Result;
            String^ Name;
            String^ DefPath;
            RegistryKey^ key;
            
            Name = "TortoiseMerge";
            DefPath = "C:\\Program Files\\TortoiseSVN\\bin\\TortoiseMerge.exe";
            key = Registry::LocalMachine->OpenSubKey("SOFTWARE\\TortoiseSVN");
            if (key)
            {
                Result = Connect::RemoveQuotes((String^) key->GetValue("TMergePath"));
            }
            if (!Result && File::Exists(DefPath))
            {
                Result = DefPath;
            }
            if (Result)
            {
                DetectedTools->Add(Name, Result);    
            }
            Result = nullptr;
            
            Name = "WinMerge";
            DefPath = "C:\\Program Files\\WinMerge\\WinMergeU.exe";
            key = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\WinMerge.exe");
            if (key)
            {
                Result = Connect::RemoveQuotes((String^) key->GetValue(nullptr));
            }
            if (!Result && File::Exists(DefPath))
            {
                Result = DefPath;
            }
            if (Result)
            {
                DetectedTools->Add(Name, Result);    
            }
            Result = nullptr;
            
            Name = "Microsoft Diff and Merge";
            key = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\9.0");
            if (key)
            {
                String^ Path = (String^) key->GetValue("InstallDir");
                Path += "DiffMerge.Exe";
                if (File::Exists(Path))
                    Result = Path;    
            }
            if (!Result)
            {
                key = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\8.0");    
                if (key)
                {
                    String^ Path = (String^) key->GetValue("InstallDir");
                    Path += "DiffMerge.Exe";
                    if (File::Exists(Path))
                        Result = Path;
                }
            }
            if (Result)
            {
                DetectedTools->Add(Name, Result);    
            }
            Result = nullptr;
            
            Name = "Beyond Compare 2";
            DefPath = "c:\\Program Files\\Beyond Compare 2\\BC2.exe";
            key = Registry::CurrentUser->OpenSubKey("SOFTWARE\\Scooter Software\\Beyond Compare");
            if (key)
            {
                Result = Connect::RemoveQuotes((String^) key->GetValue("ExePath"));
            }
            if (!Result && File::Exists(DefPath))
            {
                Result = DefPath;
            }
            if (Result)
            {
                DetectedTools->Add(Name, Result);    
            }
            Result = nullptr;
            
            Name = "Araxis Merge";
            DefPath = "C:\\Program Files\\Araxis\\Araxis Merge\\compare.exe";
            key = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\merge.exe");
            if (key)
            {
                Result = Connect::RemoveQuotes((String^) key->GetValue(nullptr));
                Result = System::IO::Path::GetDirectoryName(Result) + "\\compare.exe";
            }
            if (!Result && File::Exists(DefPath))
            {
                Result = DefPath;
            }
            if (Result)
            {
                DetectedTools->Add(Name, Result);    
            }
            Result = nullptr;
            
            // detected tools : combobox
			IDictionaryEnumerator^ Enumerator2 = DetectedTools->GetEnumerator();
            while (Enumerator2->MoveNext())
            {
                comboBoxDetectedTools->Items->Add((String^) Enumerator2->Key);
            }     
            if (comboBoxDetectedTools->Items->Count > 0)
                comboBoxDetectedTools->SelectedIndex = 0;
            
            initDone = true;
		}
		
		void ApplyConfig();
		void ReadConfig();

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~FormConfig()
		{
			if (components)
			{
				delete components;
			}
		}
	
	public:
	    Hashtable^ PredefinedArgs;
	    Hashtable^ DetectedTools;

	private:
	    Connect^ connectObject;
        bool initDone;








    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::ToolTip^  toolTip1;
    private: System::Windows::Forms::GroupBox^  groupBox1;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TextBox^  textBoxExcludedFiles;
    private: System::Windows::Forms::NumericUpDown^  numericUpDownMinTimeBetweenBackups;
    private: System::Windows::Forms::NumericUpDown^  numericUpDownRetentionTime;
    private: System::Windows::Forms::GroupBox^  groupBox2;
    private: System::Windows::Forms::PictureBox^  pictureBox1;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::TextBox^  textBoxDiffToolCommand;
    private: System::Windows::Forms::ComboBox^  comboBoxPredefinedTools;

    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::Button^  button4;
    private: System::Windows::Forms::Label^  label7;
    private: System::Windows::Forms::TextBox^  textBoxDiffToolArgs;

    private: System::Windows::Forms::Label^  labelOldNameDesc;

    private: System::Windows::Forms::Label^  labelCurrentNameDesc;

    private: System::Windows::Forms::Label^  labelOldDesc;

    private: System::Windows::Forms::Label^  labelCurrentDesc;
    private: System::Windows::Forms::Label^  labelOldNameTitle;
    private: System::Windows::Forms::Label^  labelCurrentNameTitle;
    private: System::Windows::Forms::Label^  labelOldTitle;
    private: System::Windows::Forms::Label^  labelCurrentTitle;
    private: System::Windows::Forms::OpenFileDialog^  openFileDialog;
private: System::Windows::Forms::Label^  label8;
private: System::Windows::Forms::ComboBox^  comboBoxDetectedTools;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::CheckBox^  checkBox1;
private: System::Windows::Forms::TextBox^  textBoxLocation;
private: System::Windows::Forms::Label^  label9;

    private: System::ComponentModel::IContainer^  components;





    protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
            this->components = (gcnew System::ComponentModel::Container());
            System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(FormConfig::typeid));
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));
            this->textBoxExcludedFiles = (gcnew System::Windows::Forms::TextBox());
            this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->numericUpDownMinTimeBetweenBackups = (gcnew System::Windows::Forms::NumericUpDown());
            this->numericUpDownRetentionTime = (gcnew System::Windows::Forms::NumericUpDown());
            this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
            this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
            this->label8 = (gcnew System::Windows::Forms::Label());
            this->comboBoxDetectedTools = (gcnew System::Windows::Forms::ComboBox());
            this->labelOldNameDesc = (gcnew System::Windows::Forms::Label());
            this->labelCurrentNameDesc = (gcnew System::Windows::Forms::Label());
            this->labelOldDesc = (gcnew System::Windows::Forms::Label());
            this->labelCurrentDesc = (gcnew System::Windows::Forms::Label());
            this->labelOldNameTitle = (gcnew System::Windows::Forms::Label());
            this->labelCurrentNameTitle = (gcnew System::Windows::Forms::Label());
            this->labelOldTitle = (gcnew System::Windows::Forms::Label());
            this->labelCurrentTitle = (gcnew System::Windows::Forms::Label());
            this->label7 = (gcnew System::Windows::Forms::Label());
            this->textBoxDiffToolArgs = (gcnew System::Windows::Forms::TextBox());
            this->button4 = (gcnew System::Windows::Forms::Button());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->comboBoxPredefinedTools = (gcnew System::Windows::Forms::ComboBox());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->textBoxDiffToolCommand = (gcnew System::Windows::Forms::TextBox());
            this->openFileDialog = (gcnew System::Windows::Forms::OpenFileDialog());
            this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
            this->textBoxLocation = (gcnew System::Windows::Forms::TextBox());
            this->label9 = (gcnew System::Windows::Forms::Label());
            this->groupBox1->SuspendLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownMinTimeBetweenBackups))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownRetentionTime))->BeginInit();
            this->groupBox2->SuspendLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button1->Location = System::Drawing::Point(178, 445);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 10;
            this->button1->Text = L"OK";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->VisibleChanged += gcnew System::EventHandler(this, &FormConfig::button1_VisibleChanged);
            this->button1->Click += gcnew System::EventHandler(this, &FormConfig::button1_Click);
            // 
            // button2
            // 
            this->button2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button2->Location = System::Drawing::Point(259, 445);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(75, 23);
            this->button2->TabIndex = 11;
            this->button2->Text = L"Cancel";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &FormConfig::button2_Click);
            // 
            // button3
            // 
            this->button3->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button3->Enabled = false;
            this->button3->Location = System::Drawing::Point(340, 445);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(75, 23);
            this->button3->TabIndex = 12;
            this->button3->Text = L"Apply";
            this->button3->UseVisualStyleBackColor = true;
            this->button3->Click += gcnew System::EventHandler(this, &FormConfig::button3_Click);
            // 
            // textBoxExcludedFiles
            // 
            this->textBoxExcludedFiles->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBoxExcludedFiles->Location = System::Drawing::Point(6, 32);
            this->textBoxExcludedFiles->Name = L"textBoxExcludedFiles";
            this->textBoxExcludedFiles->Size = System::Drawing::Size(391, 20);
            this->textBoxExcludedFiles->TabIndex = 1;
            this->toolTip1->SetToolTip(this->textBoxExcludedFiles, L"you can use the asterisk and question mark to specify file patterns. For example " 
                L": *.exe;foo*.b\?r;and.so.on");
            this->textBoxExcludedFiles->TextChanged += gcnew System::EventHandler(this, &FormConfig::textBoxExcludedFiles_TextChanged_1);
            // 
            // groupBox1
            // 
            this->groupBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->groupBox1->Controls->Add(this->label5);
            this->groupBox1->Controls->Add(this->label2);
            this->groupBox1->Controls->Add(this->label1);
            this->groupBox1->Controls->Add(this->textBoxExcludedFiles);
            this->groupBox1->Controls->Add(this->numericUpDownMinTimeBetweenBackups);
            this->groupBox1->Controls->Add(this->numericUpDownRetentionTime);
            this->groupBox1->Location = System::Drawing::Point(12, 38);
            this->groupBox1->Name = L"groupBox1";
            this->groupBox1->Size = System::Drawing::Size(403, 139);
            this->groupBox1->TabIndex = 16;
            this->groupBox1->TabStop = false;
            this->groupBox1->Text = L"History options";
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(3, 94);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(197, 13);
            this->label5->TabIndex = 15;
            this->label5->Text = L"Min. time between backups (in seconds)";
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(3, 55);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(195, 13);
            this->label2->TabIndex = 14;
            this->label2->Text = L"Max. days to keep backups (0 = infinite)";
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(3, 16);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(194, 13);
            this->label1->TabIndex = 13;
            this->label1->Text = L"Excluded files (example: *.exe;version.*)";
            // 
            // numericUpDownMinTimeBetweenBackups
            // 
            this->numericUpDownMinTimeBetweenBackups->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->numericUpDownMinTimeBetweenBackups->Location = System::Drawing::Point(6, 110);
            this->numericUpDownMinTimeBetweenBackups->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {86400, 0, 0, 0});
            this->numericUpDownMinTimeBetweenBackups->Name = L"numericUpDownMinTimeBetweenBackups";
            this->numericUpDownMinTimeBetweenBackups->Size = System::Drawing::Size(391, 20);
            this->numericUpDownMinTimeBetweenBackups->TabIndex = 3;
            this->numericUpDownMinTimeBetweenBackups->ValueChanged += gcnew System::EventHandler(this, &FormConfig::numericUpDownMinTimeBetweenBackups_ValueChanged_1);
            // 
            // numericUpDownRetentionTime
            // 
            this->numericUpDownRetentionTime->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->numericUpDownRetentionTime->Location = System::Drawing::Point(6, 71);
            this->numericUpDownRetentionTime->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {365, 0, 0, 0});
            this->numericUpDownRetentionTime->Name = L"numericUpDownRetentionTime";
            this->numericUpDownRetentionTime->Size = System::Drawing::Size(391, 20);
            this->numericUpDownRetentionTime->TabIndex = 2;
            this->numericUpDownRetentionTime->ValueChanged += gcnew System::EventHandler(this, &FormConfig::numericUpDownRetentionTime_ValueChanged_1);
            // 
            // groupBox2
            // 
            this->groupBox2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->groupBox2->Controls->Add(this->linkLabel1);
            this->groupBox2->Controls->Add(this->label8);
            this->groupBox2->Controls->Add(this->comboBoxDetectedTools);
            this->groupBox2->Controls->Add(this->labelOldNameDesc);
            this->groupBox2->Controls->Add(this->labelCurrentNameDesc);
            this->groupBox2->Controls->Add(this->labelOldDesc);
            this->groupBox2->Controls->Add(this->labelCurrentDesc);
            this->groupBox2->Controls->Add(this->labelOldNameTitle);
            this->groupBox2->Controls->Add(this->labelCurrentNameTitle);
            this->groupBox2->Controls->Add(this->labelOldTitle);
            this->groupBox2->Controls->Add(this->labelCurrentTitle);
            this->groupBox2->Controls->Add(this->label7);
            this->groupBox2->Controls->Add(this->textBoxDiffToolArgs);
            this->groupBox2->Controls->Add(this->button4);
            this->groupBox2->Controls->Add(this->label6);
            this->groupBox2->Controls->Add(this->comboBoxPredefinedTools);
            this->groupBox2->Controls->Add(this->label4);
            this->groupBox2->Controls->Add(this->pictureBox1);
            this->groupBox2->Controls->Add(this->label3);
            this->groupBox2->Controls->Add(this->textBoxDiffToolCommand);
            this->groupBox2->Location = System::Drawing::Point(12, 183);
            this->groupBox2->Name = L"groupBox2";
            this->groupBox2->Size = System::Drawing::Size(403, 229);
            this->groupBox2->TabIndex = 17;
            this->groupBox2->TabStop = false;
            this->groupBox2->Text = L"External comparison tool";
            // 
            // linkLabel1
            // 
            this->linkLabel1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->linkLabel1->AutoSize = true;
            this->linkLabel1->Location = System::Drawing::Point(244, 57);
            this->linkLabel1->Name = L"linkLabel1";
            this->linkLabel1->Size = System::Drawing::Size(109, 13);
            this->linkLabel1->TabIndex = 7;
            this->linkLabel1->TabStop = true;
            this->linkLabel1->Text = L"Find comparison tools";
            this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &FormConfig::linkLabel1_LinkClicked);
            // 
            // label8
            // 
            this->label8->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->label8->AutoSize = true;
            this->label8->Location = System::Drawing::Point(244, 17);
            this->label8->Name = L"label8";
            this->label8->Size = System::Drawing::Size(57, 13);
            this->label8->TabIndex = 18;
            this->label8->Text = L"Detected :";
            // 
            // comboBoxDetectedTools
            // 
            this->comboBoxDetectedTools->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->comboBoxDetectedTools->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
            this->comboBoxDetectedTools->FormattingEnabled = true;
            this->comboBoxDetectedTools->Location = System::Drawing::Point(247, 33);
            this->comboBoxDetectedTools->Name = L"comboBoxDetectedTools";
            this->comboBoxDetectedTools->Size = System::Drawing::Size(150, 21);
            this->comboBoxDetectedTools->Sorted = true;
            this->comboBoxDetectedTools->TabIndex = 6;
            this->comboBoxDetectedTools->SelectedIndexChanged += gcnew System::EventHandler(this, &FormConfig::comboBoxDetectedTools_SelectedIndexChanged);
            // 
            // labelOldNameDesc
            // 
            this->labelOldNameDesc->AutoSize = true;
            this->labelOldNameDesc->Location = System::Drawing::Point(18, 207);
            this->labelOldNameDesc->Name = L"labelOldNameDesc";
            this->labelOldNameDesc->Size = System::Drawing::Size(214, 13);
            this->labelOldNameDesc->TabIndex = 16;
            this->labelOldNameDesc->Text = L"Displayed name for the selected old revision";
            // 
            // labelCurrentNameDesc
            // 
            this->labelCurrentNameDesc->AutoSize = true;
            this->labelCurrentNameDesc->Location = System::Drawing::Point(18, 181);
            this->labelCurrentNameDesc->Name = L"labelCurrentNameDesc";
            this->labelCurrentNameDesc->Size = System::Drawing::Size(190, 13);
            this->labelCurrentNameDesc->TabIndex = 15;
            this->labelCurrentNameDesc->Text = L"Displayed name for the current revision";
            // 
            // labelOldDesc
            // 
            this->labelOldDesc->AutoSize = true;
            this->labelOldDesc->Location = System::Drawing::Point(18, 155);
            this->labelOldDesc->Name = L"labelOldDesc";
            this->labelOldDesc->Size = System::Drawing::Size(105, 13);
            this->labelOldDesc->TabIndex = 14;
            this->labelOldDesc->Text = L"Selected old revision";
            // 
            // labelCurrentDesc
            // 
            this->labelCurrentDesc->AutoSize = true;
            this->labelCurrentDesc->Location = System::Drawing::Point(18, 129);
            this->labelCurrentDesc->Name = L"labelCurrentDesc";
            this->labelCurrentDesc->Size = System::Drawing::Size(165, 13);
            this->labelCurrentDesc->TabIndex = 13;
            this->labelCurrentDesc->Text = L"Current (latest or opened) revision";
            // 
            // labelOldNameTitle
            // 
            this->labelOldNameTitle->AutoSize = true;
            this->labelOldNameTitle->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Underline, 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->labelOldNameTitle->Location = System::Drawing::Point(3, 194);
            this->labelOldNameTitle->Name = L"labelOldNameTitle";
            this->labelOldNameTitle->Size = System::Drawing::Size(29, 13);
            this->labelOldNameTitle->TabIndex = 12;
            this->labelOldNameTitle->Text = L"label";
            // 
            // labelCurrentNameTitle
            // 
            this->labelCurrentNameTitle->AutoSize = true;
            this->labelCurrentNameTitle->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Underline, 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->labelCurrentNameTitle->Location = System::Drawing::Point(3, 168);
            this->labelCurrentNameTitle->Name = L"labelCurrentNameTitle";
            this->labelCurrentNameTitle->Size = System::Drawing::Size(29, 13);
            this->labelCurrentNameTitle->TabIndex = 11;
            this->labelCurrentNameTitle->Text = L"label";
            // 
            // labelOldTitle
            // 
            this->labelOldTitle->AutoSize = true;
            this->labelOldTitle->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->labelOldTitle->Location = System::Drawing::Point(3, 142);
            this->labelOldTitle->Name = L"labelOldTitle";
            this->labelOldTitle->Size = System::Drawing::Size(29, 13);
            this->labelOldTitle->TabIndex = 10;
            this->labelOldTitle->Text = L"label";
            // 
            // labelCurrentTitle
            // 
            this->labelCurrentTitle->AutoSize = true;
            this->labelCurrentTitle->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Underline, 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->labelCurrentTitle->Location = System::Drawing::Point(3, 116);
            this->labelCurrentTitle->Name = L"labelCurrentTitle";
            this->labelCurrentTitle->Size = System::Drawing::Size(29, 13);
            this->labelCurrentTitle->TabIndex = 0;
            this->labelCurrentTitle->Text = L"label";
            // 
            // label7
            // 
            this->label7->AutoSize = true;
            this->label7->Location = System::Drawing::Point(3, 77);
            this->label7->Name = L"label7";
            this->label7->Size = System::Drawing::Size(63, 13);
            this->label7->TabIndex = 8;
            this->label7->Text = L"Arguments :";
            // 
            // textBoxDiffToolArgs
            // 
            this->textBoxDiffToolArgs->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBoxDiffToolArgs->Location = System::Drawing::Point(6, 93);
            this->textBoxDiffToolArgs->Name = L"textBoxDiffToolArgs";
            this->textBoxDiffToolArgs->Size = System::Drawing::Size(235, 20);
            this->textBoxDiffToolArgs->TabIndex = 8;
            this->textBoxDiffToolArgs->TextChanged += gcnew System::EventHandler(this, &FormConfig::textBoxDiffToolArgs_TextChanged);
            // 
            // button4
            // 
            this->button4->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->button4->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
            this->button4->Location = System::Drawing::Point(215, 32);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(26, 20);
            this->button4->TabIndex = 5;
            this->button4->Text = L"...";
            this->button4->UseVisualStyleBackColor = true;
            this->button4->Click += gcnew System::EventHandler(this, &FormConfig::button4_Click);
            // 
            // label6
            // 
            this->label6->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->label6->AutoSize = true;
            this->label6->Location = System::Drawing::Point(244, 77);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(64, 13);
            this->label6->TabIndex = 5;
            this->label6->Text = L"Predefined :";
            // 
            // comboBoxPredefinedTools
            // 
            this->comboBoxPredefinedTools->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
            this->comboBoxPredefinedTools->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
            this->comboBoxPredefinedTools->FormattingEnabled = true;
            this->comboBoxPredefinedTools->Location = System::Drawing::Point(247, 93);
            this->comboBoxPredefinedTools->Name = L"comboBoxPredefinedTools";
            this->comboBoxPredefinedTools->Size = System::Drawing::Size(150, 21);
            this->comboBoxPredefinedTools->Sorted = true;
            this->comboBoxPredefinedTools->TabIndex = 9;
            this->comboBoxPredefinedTools->SelectedIndexChanged += gcnew System::EventHandler(this, &FormConfig::comboBoxPredefinedTools_SelectedIndexChanged);
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->ForeColor = System::Drawing::Color::Red;
            this->label4->Location = System::Drawing::Point(28, 55);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(143, 13);
            this->label4->TabIndex = 3;
            this->label4->Text = L"The path seems to be invalid";
            // 
            // pictureBox1
            // 
            this->pictureBox1->BackColor = System::Drawing::SystemColors::Control;
            this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
            this->pictureBox1->InitialImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.InitialImage")));
            this->pictureBox1->Location = System::Drawing::Point(6, 54);
            this->pictureBox1->Name = L"pictureBox1";
            this->pictureBox1->Size = System::Drawing::Size(16, 16);
            this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
            this->pictureBox1->TabIndex = 2;
            this->pictureBox1->TabStop = false;
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(3, 16);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(60, 13);
            this->label3->TabIndex = 1;
            this->label3->Text = L"Command :";
            // 
            // textBoxDiffToolCommand
            // 
            this->textBoxDiffToolCommand->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBoxDiffToolCommand->Location = System::Drawing::Point(6, 32);
            this->textBoxDiffToolCommand->Name = L"textBoxDiffToolCommand";
            this->textBoxDiffToolCommand->Size = System::Drawing::Size(203, 20);
            this->textBoxDiffToolCommand->TabIndex = 4;
            this->textBoxDiffToolCommand->TextChanged += gcnew System::EventHandler(this, &FormConfig::textBoxDiffToolCommand_TextChanged);
            // 
            // openFileDialog
            // 
            this->openFileDialog->AddExtension = false;
            this->openFileDialog->Filter = L"Programs (*.exe)|*.exe|All files|*.*";
            this->openFileDialog->SupportMultiDottedExtensions = true;
            this->openFileDialog->Title = L"Select comparison tool";
            // 
            // checkBox1
            // 
            this->checkBox1->AutoSize = true;
            this->checkBox1->Location = System::Drawing::Point(12, 418);
            this->checkBox1->Name = L"checkBox1";
            this->checkBox1->Size = System::Drawing::Size(196, 17);
            this->checkBox1->TabIndex = 18;
            this->checkBox1->Text = L"Automatically check for new version";
            this->checkBox1->UseVisualStyleBackColor = true;
            this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &FormConfig::checkBox1_CheckedChanged);
            // 
            // textBoxLocation
            // 
            this->textBoxLocation->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBoxLocation->Location = System::Drawing::Point(112, 12);
            this->textBoxLocation->Name = L"textBoxLocation";
            this->textBoxLocation->ReadOnly = true;
            this->textBoxLocation->Size = System::Drawing::Size(303, 20);
            this->textBoxLocation->TabIndex = 19;
            // 
            // label9
            // 
            this->label9->AutoSize = true;
            this->label9->Location = System::Drawing::Point(15, 15);
            this->label9->Name = L"label9";
            this->label9->Size = System::Drawing::Size(91, 13);
            this->label9->TabIndex = 20;
            this->label9->Text = L"Configuration file :";
            // 
            // FormConfig
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(427, 480);
            this->Controls->Add(this->label9);
            this->Controls->Add(this->textBoxLocation);
            this->Controls->Add(this->checkBox1);
            this->Controls->Add(this->groupBox2);
            this->Controls->Add(this->groupBox1);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->MaximizeBox = false;
            this->MinimizeBox = false;
            this->MinimumSize = System::Drawing::Size(443, 516);
            this->Name = L"FormConfig";
            this->ShowIcon = false;
            this->ShowInTaskbar = false;
            this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
            this->Text = L"VLH2005 Settings";
            this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &FormConfig::FormConfig_FormClosing);
            this->groupBox1->ResumeLayout(false);
            this->groupBox1->PerformLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownMinTimeBetweenBackups))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownRetentionTime))->EndInit();
            this->groupBox2->ResumeLayout(false);
            this->groupBox2->PerformLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion
    private: 
        System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            Visible = false;
        }
    private: 
        System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            try
            {
                ApplyConfig();
                ConnectObject->CleanHistoryDirectory();
                ConnectObject->UpdateHistoryWindow();
            }
            catch (...)
            {
            }
            button3->Enabled = false;
        }
    private:
        System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            Visible = false;
            ApplyConfig();
            ConnectObject->CleanHistoryDirectory();
            ConnectObject->UpdateHistoryWindow();
        }
    private: 
        System::Void button1_VisibleChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            if (Visible)
            {
                ReadConfig();
                textBoxLocation->Text = ConnectObject->config->Location;
                button3->Enabled = false;
            }
        }
    private: 
        System::Void textBoxExcludedFiles_TextChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void numericUpDownRetentionTime_ValueChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void numericUpDownMinTimeBetweenBackups_ValueChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void textBoxDiffToolCommand_TextChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            try
            {
                String^ Command = textBoxDiffToolCommand->Text->Trim();
                pictureBox1->Visible = Command->Length > 0 && !File::Exists(Command);
                label4->Visible = pictureBox1->Visible;
            }
            catch(...)
            {
                pictureBox1->Visible = true;
                label4->Visible = true;
            }
            button3->Enabled = true;
        }
    private: 
        System::Void comboBoxPredefinedTools_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            if (initDone && comboBoxPredefinedTools->SelectedIndex >= 0)
            {
                textBoxDiffToolArgs->Text = (String^) PredefinedArgs[((String^) comboBoxPredefinedTools->SelectedItem)];
            }    
        }
    private: 
        System::Void textBoxDiffToolArgs_TextChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void textBoxExcludedFiles_TextChanged_1(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void numericUpDownRetentionTime_ValueChanged_1(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void numericUpDownMinTimeBetweenBackups_ValueChanged_1(System::Object^  sender, System::EventArgs^  e) 
        {
            button3->Enabled = true;
        }
    private: 
        System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            if (System::Windows::Forms::DialogResult::OK == openFileDialog->ShowDialog())
            {
                textBoxDiffToolCommand->Text = openFileDialog->FileName;
            }
        }
    private: 
        System::Void comboBoxDetectedTools_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
        {
            if (initDone && comboBoxDetectedTools->SelectedIndex >= 0)
            {
                textBoxDiffToolCommand->Text = (String^) DetectedTools[((String^) comboBoxDetectedTools->SelectedItem)];
                comboBoxPredefinedTools->SelectedItem = (String^) comboBoxDetectedTools->SelectedItem;
            }    
        }
    private: 
        System::Void linkLabel1_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) 
        {
            System::Diagnostics::Process::Start("http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools");
        }
private: System::Void FormConfig_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {e->Cancel = true; Visible = false;
         }
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
button3->Enabled = true;
         }
};
}
